<template>
	<div class="icons">
		<swiper :options="swiperOption">
			<swiper-slide v-for="(page,index) of pages" :key="index">
				<div class="icon" v-for="itme of page" :key="itme.id">
					<div class="icon-img">
						<img class="icon-img-1" :src="itme.imgUrl"/>
					</div>
					<p>{{itme.desc}}</p>
				</div>
			</swiper-slide>
		</swiper>
	</div>
</template>

<script>
	export default {
		name:'HomeIcon',
		props:{
			list:Array
		},
		data(){
			return{
				swiperOption:{
					autoplay:false
				}
			}
		},
		computed:{
			pages () {
				const pages = []
				//forEach  itme代表每一项， index代表下表
				this.list.forEach((itme,index) =>{
					//Math.floor 四舍五入  1/8四舍五入 0  以此类推， 因为有9个， 所以前8个都是第0页的  第9个是第一页
					const page = Math.floor(index/8);
					if(!pages[page]){
						pages[page]=[];
					}
					pages[page].push(itme)
				})
				return pages
			}
		}
	}
</script>

<style scoped>
.icons >>> .swiper-container{
	background: #fff;
	margin-top: 0.1rem;
	height: 3.2rem;
}	
.icon{
	width: 25%;
	float: left;
	height: 1.6rem;
	background: #fff;
	position: relative;
	text-align: center;
}
.icon-img{
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0.44rem;
	text-align: center;
	display: table-cell;
	vertical-align: middle;
}
.icon-img-1{
	width: 1.1rem;
	height: 1.1rem;
}
.icon p{
	position: absolute;
	left: 0;
	bottom: 0.1rem;
	width: 100%;
	text-align: center;
	font-size:0.24rem;
	color: #212121;
	overflow : hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
</style>